package main

import "fmt"

func Slice() {
	//a1 := []int{1, 2, 3}
	//fmt.Printf("a1=%v\n", a1)
	//a2 := make([]int, 3, 5)
	////make([]int,0,5)
	//fmt.Printf("len:%d,cap:%d", len(a2), cap(a2))
	a3 := make([]int, 0, 4)
	a3 = append(a3, 3)
	fmt.Printf("a3:%v len:%d,cap:%d", a3, len(a3), cap(a3))

}
func ShareSlice() {
	s1 := []int{1, 2, 3, 4, 5}
	s2 := s1[2:3]
	fmt.Printf("s2:%v len:%d,cap:%d\n", s2, len(s2), cap(s2))

	s2[0] = 22
	fmt.Printf("s2:%v len:%d,cap:%d\n", s2, len(s2), cap(s2))
	fmt.Printf("s1:%v len:%d,cap:%d\n", s1, len(s1), cap(s1))

	s2 = append(s2, 123)
	fmt.Printf("s2:%v len:%d,cap:%d\n", s2, len(s2), cap(s2))
	fmt.Printf("s1:%v len:%d,cap:%d\n", s1, len(s1), cap(s1))

}
